package com.na.proxy;

public class Main {

	static final int PORT = 9527; // DEFAULT PORT
	
	public static void main(final String[] args) {
		final ProxyServer server = new ProxyServer(parsePort(args));
		server.open();
		Runtime.getRuntime().addShutdownHook(new Thread() {
			@Override
			public void run() {
				server.close();
			}
		});
	}
	
	private static int parsePort(String[] args) {
		if (args != null && args.length > 0) {
			try {
				return Integer.parseInt(args[0]);
			} catch (NumberFormatException e) {
			}
		}
		return PORT;
	}
	
}
